UploadCtl.SetTreeViewColor Method

Applies to: SharePoint Foundation 2010

Sets the background color of the tree view used to display the local folders from which to select documents for uploading.

expression.SetTreeViewColor(newVal)

Parameters

expression

An expression that returns an UploadCtl Control object.

newVal

A hexadecimal string value of the form #aabbcc representing the color.

Remarks

The following example steps through the process of adding an UploadCtl control to an .aspx page for uploading multiple documents to the Shared Documents folder of a specified site. The example adds a hidden UploadCtl control within the page that is displayed when a link is clicked.

The .aspx file, in this example WebForm1.aspx, must be located in the %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS directory, and is opened through the URL https://Server_Name/_layouts/WebForm1.aspx.

  1. Add a page directive that registers the Microsoft.SharePoint.WebControls namespace:

    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
    PublicKeyToken=71e9bce111e9429c" %>
    
  2. Add a LINK element in the HEAD section to apply Microsoft SharePoint Foundation styles that are defined in ows.css:

    <LINK REL="stylesheet" TYPE="text/css" 
       HREF="/_layouts/1033/styles/ows.css">
    
  3. Add a script block to the HEAD section that includes two methods. One method sets the background color for the tree view and displays the UploadCtl on the page. The other method uploads documents that are selected in the control.

    <SCRIPT LANGUAGE="javascript">
    function MultipleUploadView()
    {
        document.all.idUploadCtl.SetTreeViewColor("#FF0000");
        document.all("idMultipleView").style.display="inline";
    }
    
    function DocumentUpload()
    {
        document.all.idUploadCtl.MultipleUpload();
    }
    </SCRIPT>
    
  4. Add a form within the BODY section of the .aspx page:

    <FORM NAME="frmUpload" METHOD="post"
       ACTION="WebForm1.aspx?RootFolder=&amp; Source=
          http%3A%2F%2FServer_Name%2FShared%2520Documents
          %2FForms%2FAllItems%2Easpx">
    
  5. To upload documents and thereby modify data within a SharePoint site, you must include a FormDigest server control in the form:

    <SharePoint:FormDigest runat="server" />
    
  6. Include INPUT elements that specify the required parameters of the post:

    <INPUT TYPE="hidden" NAME="Cmd" VALUE="Save">
    <INPUT TYPE="hidden" NAME="NextUsing"
       VALUE="http://Server_Name/
           Shared%20Documents/Forms/AllItems.aspx">
    <INPUT TYPE="hidden" VALUE="New">
    <INPUT TYPE="hidden" NAME="putopts" VALUE="true">
    <INPUT TYPE="hidden" NAME="destination"
       VALUE="http://Server_Name/Shared Documents">
    <INPUT TYPE="hidden" NAME="Confirmation-URL"
       VALUE="http://Server_Name/Shared%20Documents/
          Forms/AllItems.aspx">
    <INPUT TYPE="hidden" NAME="PostURL"
       VALUE="http%3a%2f%2fServer_Name/_vti_bin/
          shtml.dll/_layouts%2fWebForm1%2easpx" />
    <INPUT TYPE="hidden" NAME="VTI-GROUP" VALUE="0">
    
  7. To complete the form, add a link for calling the MultipleUploadView method and displaying the contents of a DIV section, which includes the <OBJECT> tag that creates the control on the page:

    <P CLASS="ms-toolbar">
       <A HREF="javascript:MultipleUploadView()"
          TARGET="_self">Upload Multiple Files</A>
    </P>
    <DIV ID=idMultipleView style='display:none'>
    <P CLASS="ms-toolbar">
       <A HREF="javascript:DocumentUpload()"
          TARGET="_self">Save and Close</A>
    </P>
    <OBJECT id=idUploadCtl name=idUploadCtl
          CLASSID=CLSID:07B06095-5687-4d13-9E32-12B4259C9813
          WIDTH='100%' HEIGHT='350px'>
    </OBJECT>
    </DIV>
    </FORM>